<script type="text/javascript">
        $(".ajax").colorbox({width:"75%", height:"75%"});
</script>

<?php
	require("../Connections/mlu.php");
  $query="select data from ordini group by data";
  $view1 = mysql_query($query, $mlu) or die(mysql_error());
  while ($row1= mysql_fetch_assoc($view1))
  {
  	echo "<h3>$row1[data]</h3>";
  $query="select idordine,count(*) as conto ,round(sum(prezzo)/2,2) as prezzo from carrelli join ordini using(idordine) join depositati using (idmlu) where ordini.data='$row1[data]' group by idordine;";
  $view = mysql_query($query, $mlu) or die(mysql_error());
  ?>
  <table border="1" width="100%">
  <?php
  $i=0;
  	while ($row= mysql_fetch_assoc($view))
	{
		$c=$row['conto'];
		switch ($c)
		{
			case 1:$color="#FFFFFF"; break;		//bianco
			case 2:$color="#00FFFF"; break;		//verde
			case 3:$color="#FFFF00"; break;		//azzurro
			case 4:
			case 5:
			case 6:$color="#FF00FF"; break;		//fucsia
			case 7:
			case 8:
			case 9:
			default:$color="#00ffae"; break;		//verde acqua
			
		}
        if ($i%5==0) {?> 
        <tr>
         <?php } ?>
        <td bgcolor="<?php echo $color; ?>"><b><a href="carrelli/view.php?o=<?php echo $row['idordine']?>" class="ajax"><?php echo $row['idordine'];?> </a></b></td>
		<td bgcolor="<?php echo $color; ?>"><i><?php echo $row['prezzo']; ?> </i></td>
        <td bgcolor="<?php echo $color; ?>"><i><?php echo $c; ?> </i></td>
        <?php if ($i%5==4) { ?>
         </tr>
          <?php } 
		$i++;
		 } ?>
        <?php if ($i!=0) { ?> </tr> <?php } ?>
		</table>
        <br /><br /><hr />
<?php  }
?>
